<template>
	<view class="container">
		<!-- <carHeader :title="'收支明细'"></carHeader> -->
		<view class="carHeader">
			<!-- <view class="car-header-top"> -->
				<uni-nav-bar @clickLeft="back" color="white" :border="false" background-color="rgba(255,255,255,0.0)"
					left-icon="left" :title="'收支明细'">
				</uni-nav-bar>
				<!-- <image @click="back" src="../../static/返回 (1).png"></image>
				<view>收支明细</view>
				<image src=""></image> -->
			<!-- </view> -->
		</view>
		<view class="rongqi">
			<view class="tixian">
				<view style="margin-left: 90rpx;font-size: 40rpx;">{{balance}}</view>
				<view style="margin-left: 30rpx;">当前现金余额 (元)</view>
				<view>
					<button class="anniu" @click="tx">
						提现
					</button>
				</view>
			</view>

			<view class="zojie">
				<view class="">
					累计收入：<span>{{income}}</span>元
				</view>

				<view class="" style="margin-top: 20rpx;">
					累计提现：<span>{{withdrawal}}</span>元
				</view>
			</view>
		</view>

		<!-- 详细账单 -->
		<view class="zhangdan">
			<view class="biaoti">
				收支明细
			</view>
			<block v-for="item in orderList" :key="item">
				<view class="neirong">
					<view class="">
						<view style="font-size: 30rpx;font-weight: 600;">
							{{ item.serviceDetails.name }}
						</view>
						<view style="font-size: 25rpx;font-weight: 100;">
							核销时间:{{ item.verificationTime }}
						</view>
					</view>
					<view style="color: red;font-size: 30rpx;font-weight: 550;">
						+ {{ item.payPrice }}
					</view>
				</view>
			</block>
			<block v-for="item in withdrawalList" :key="item">
				<view class="neirong">
					<view class="">
						<view style="font-size: 30rpx;font-weight: 600;">
							提现
						</view>
						<view style="font-size: 25rpx;font-weight: 100;">
							提现时间:{{ item.withdrawalTime }}
						</view>
					</view>
					<view style="color: red;font-size: 30rpx;font-weight: 550;">
						- {{ item.cashWithdrawal }}
					</view>
				</view>
			</block>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				// shopId: 1,
				balance: 0, // 账户余额
				income: 0, // 累计收入
				withdrawal: 0, // 提现金额
				orderList: [],
				withdrawalList: [],
				items: [{
						title: '车辆清洗, 抛光打蜡服务',
						time: '2022-10-12 11:09',
						amount: '+ 50.00'
					},
					{
						title: '车辆清洗, 抛光打蜡服务',
						time: '2022-10-12 11:09',
						amount: '+ 50.00'
					}
				]
			}
		},
		// 页面加载时
		onLoad() {
			// 获取商家id，赋值给 shopId
			this.getBalance();
		},
		methods: {
			back() {
				console.log("该返回了")
				uni.redirectTo({
					url: "/pages/home/home"
				})
			},
			// 获取 账户余额、累计收入、累计提现金额
			getBalance() {
				uni.request({
					url: "http://localhost:8080/carShop/shopStatistics/getBalance",
					method: "GET",
					success: (res) => {
						console.log(res.data.data);
						this.balance = res.data.data.balance;
						this.income = res.data.data.income;
						this.withdrawal = res.data.data.withdrawal;
						this.orderList = res.data.data.orderList;
						this.withdrawalList = res.data.data.withdrawalList;
					}
				})
			},
			tx() {
				uni.navigateTo({
					url: "/pages/application/application?balance=" + this.balance
				})
			}
		}
	}
</script>

<style>
	.container {
		position: relative;
		/* 添加此行 */
	}

	.carHeader {
		z-index: 45;
		height: 380rpx;
		background-image: url("../../static/车联网服务商家端-00登录_slices/组 6.png");
	}
	.car-header-top{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		line-height: 100rpx;
		align-items: center;
		padding-top: 20rpx;
		color: #fff;
	}
	.car-header-top image{
		/* background-color: #d0eeec; */
		width: 60rpx;
		height: 60rpx;
	}

	.rongqi {
		display: flex;
		position: absolute;
		/* 添加此行 */
		top: 120rpx;
		/* 根据需要调整数值 */
		left: 5%;
		width: 90%;
	}

	.tixian {
		margin-left: 30rpx;
		width: 46%;
		border-right: 2rpx solid yellow;
		margin-top: 20rpx;
		color: azure;
	}

	.anniu {
		width: 270rpx;
		border-radius: 90rpx;
		height: 70rpx;
		background-color: red;
		color: white;
		margin-top: 20rpx;
		margin-left: 10rpx;
		line-height: 180%
	}

	.zojie {
		margin-left: 60rpx;
		margin-top: 80rpx;
		color: white;
	}

	/* 收支明细账单 */
	.zhangdan {
		width: 92%;

		margin-left: 4%;
		background-color: white;
		position: relative;
		/* 添加定位 */
		top: -25rpx;
		border-radius: 30rpx;
	}

	.biaoti {
		width: 90%;
		margin-left: 5%;
		height: 90rpx;
		border-bottom: 5rpx solid #d0eeec;
		/* background-color: #87cefa; */
		display: flex;
		align-items: center;
		font-size: 35rpx;
		font-weight: 700;
	}

	.neirong {
		width: 80%;
		margin-left: 5%;
		padding: 0 5%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 130rpx;
		border-bottom: 3rpx solid #eee;
	}
</style>